﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IBLL;

namespace BLL
{
    public class AdminBLL : IAdminBLL
    {
        //管理员登陆
        public bool Login(string adminName, string adminPsd, string loginIP) 
        {
            bool validator = false;
            DAL.AdminDAL adminDAL = (DAL.AdminDAL)DALFAC.DataAccess.CreateAdmin();
            if (adminDAL != null)
            {
                if (adminDAL.nameExists(adminName))
                {
                    string psd = adminDAL.getPsdByName(adminName);
                    {
                        if (psd.Equals(adminPsd)) 
                        {
                            Model.Admin adminModel = new Model.Admin();
                            adminModel = adminDAL.GetModelByName(adminName);

                            adminModel.setAD_lastLoginTime(DateTime.Now);
                            adminModel.setAD_lastLoginIP(loginIP);

                            validator = adminDAL.Update(adminModel);
                        }

                    }
                }                
            }
            return validator;
        }
    }
}
